/*
 * ClassPropertiePanel.java
 *
 * Created on 11. Juni 2008, 00:50
 */

package twi.query.template.view;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;

import javax.swing.JCheckBox;

import twi.query.template.ClassNode;

/**
 *
 * @author  Soeren
 */
public class ClassPropertiePanel extends javax.swing.JPanel {

    private ClassNode classNode;
	/** Creates new form ClassPropertiePanel */
    public ClassPropertiePanel(ClassNode classNode) {
    	this.classNode = classNode;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jCheckBox_opt = new javax.swing.JCheckBox();
        jCheckBox_edit = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        jCheckBox_res = new javax.swing.JCheckBox();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(twi_project.TWI_ProjectApp.class).getContext().getResourceMap(ClassPropertiePanel.class);
        jCheckBox_opt.setText(resourceMap.getString("jCheckBox_opt.text")); // NOI18N
        jCheckBox_opt.setName("jCheckBox_opt"); // NOI18N
        jCheckBox_opt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox_optActionPerformed(evt);
            }
        });

        jCheckBox_edit.setText(resourceMap.getString("jCheckBox_edit.text")); // NOI18N
        jCheckBox_edit.setEnabled(false);
        jCheckBox_edit.setName("jCheckBox_edit"); // NOI18N
        jCheckBox_edit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox_editActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Properties"));
        jPanel2.setName("jPanel2"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 85, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 160, Short.MAX_VALUE)
        );

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setBorder(javax.swing.BorderFactory.createTitledBorder("Filter"));
        jTextArea1.setName("jTextArea1"); // NOI18N
        jScrollPane1.setViewportView(jTextArea1);

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jCheckBox_res.setSelected(true);
        jCheckBox_res.setText(resourceMap.getString("jCheckBox_res.text")); // NOI18N
        jCheckBox_res.setName("jCheckBox_res"); // NOI18N
        jCheckBox_res.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox_resActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jCheckBox_opt)
                        .addGap(18, 18, 18)
                        .addComponent(jCheckBox_edit)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCheckBox_res))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jScrollPane1))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBox_opt)
                    .addComponent(jCheckBox_edit)
                    .addComponent(jCheckBox_res))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(8, 8, 8)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
	classNode.createIndividual();
}//GEN-LAST:event_jButton1ActionPerformed

private void jCheckBox_optActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_optActionPerformed
	classNode.setOptional(jCheckBox_opt.isSelected());
}//GEN-LAST:event_jCheckBox_optActionPerformed

private void jCheckBox_editActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_editActionPerformed
	classNode.setEditable(jCheckBox_edit.isSelected());
}//GEN-LAST:event_jCheckBox_editActionPerformed

private void jCheckBox_resActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_resActionPerformed
	classNode.setShowResult(jCheckBox_res.isSelected());
}//GEN-LAST:event_jCheckBox_resActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JCheckBox jCheckBox_edit;
    private javax.swing.JCheckBox jCheckBox_opt;
    private javax.swing.JCheckBox jCheckBox_res;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables
	public void setComboxes(ArrayList<JCheckBox> cbList) {
		this.jPanel2.removeAll();
		this.jPanel2.setLayout(new GridBagLayout());
		GridBagConstraints gc = new GridBagConstraints();
		gc.gridheight = 1;gc.gridwidth = 1;
		gc.gridx = 0; gc.gridy = 0;
		gc.anchor = GridBagConstraints.WEST;
		for (int i = 0; i < cbList.size(); i++){
			this.jPanel2.add(cbList.get(i), gc);
			gc.gridy++;
		}
	}

}
